//
//  BIActionsDimmerViewController.m
//  TicketSystem
//
//  Created by ET|冰琳 on 2017/2/15.
//  Copyright © 2017年 UK. All rights reserved.
//

#import "BIActionsDimmerViewController.h"

@interface BIActionsDimmerViewController ()

@property (nonatomic, strong) UIView *actionsContainerView;//按钮container
@property (nonatomic, strong) UIView *seperatorView;//按钮container

@end

@implementation BIActionsDimmerViewController


- (void)initialization {
    [super initialization];
    self.showLine = YES;
    self.showActionsButton = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (self.showActionsButton) {
        [self.containerView addSubview:self.actionsContainerView];
        [self.actionsContainerView addSubview:self.titleLabel];
        [self.actionsContainerView addSubview:self.confirm];
        [self.actionsContainerView addSubview:self.cancel];
        self.titleLabel.frame = CGRectMake(CGRectGetMaxX(self.cancel.frame), 0, CGRectGetMinX(self.confirm.frame) - CGRectGetMaxX(self.cancel.frame), self.actionsContainerView.frame.size.height);
        self.touchDismiss = NO;
        
        [self.confirm addTarget:self action:@selector(confirmActioned) forControlEvents:UIControlEventTouchUpInside];
        [self.cancel  addTarget:self action:@selector(cancelActioned) forControlEvents:UIControlEventTouchUpInside];
    }
    
    if (self.showLine) {
        CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
        self.seperatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 43.5, screenWidth, 0.5)];
        self.seperatorView.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.3];
        [self.actionsContainerView addSubview:self.seperatorView];
        
    }
}


#pragma mark - property
- (UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _titleLabel;
}

- (UIButton *)confirm {
    if (_confirm == nil) {
        CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
        _confirm = [UIButton buttonWithType:UIButtonTypeCustom];
        _confirm.frame = CGRectMake(screenWidth - 8 - 44, 0, 44, 44);
        _confirm.titleLabel.font = [UIFont systemFontOfSize:15];
        [_confirm setTitle:@"确定" forState:UIControlStateNormal];
        [_confirm setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
    return _confirm;
}

- (UIButton *)cancel {
    if (_cancel == nil) {
        _cancel = [UIButton buttonWithType:UIButtonTypeCustom];
        _cancel.frame = CGRectMake(8, 0, 44, 44);
        _cancel.titleLabel.font = [UIFont systemFontOfSize:15];
        [_cancel setTitle:@"取消" forState:UIControlStateNormal];
        [_cancel setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    }
    return _cancel;
}

- (UIView *)actionsContainerView {
    if (_actionsContainerView == nil) {
        CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
        _actionsContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 44)];
        //        _actionsContainerView.backgroundColor = [UIColor orangeColor];
    }
    return _actionsContainerView;
}

#pragma mark - actioned 
- (void)confirmActioned {
    
}

- (void)cancelActioned{
    [self dismissViewControllerAnimated:true completion:nil];
}

@end
